<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>AK JOB</title>
    <link rel="icon" type="image/x-icon" href="../../../layuiadmin/style/res/favicon.png"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card layui-padding-3" id="pwdForm">
        <div class="layui-form" lay-filter="pwdForm">
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    <input type="password" name="oldPassword" value="" lay-verify="required|max20" placeholder="原密码" autocomplete="off" class="layui-input" lay-affix="eye" lay-verType="tips">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    <input type="password" name="newPassword" value="" lay-verify="required|max20" placeholder="新密码" autocomplete="off" class="layui-input" id="reg-password" lay-affix="eye" lay-verType="tips">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    <input type="password" name="confirmPassword" value="" lay-verify="required|confirmPassword|max20" placeholder="确认新密码" autocomplete="off" class="layui-input" lay-affix="eye" lay-verType="tips">
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="pwdForm-submit"><提交></提交></button>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="table-tool">

</script>


<script src="../../../layuiadmin/layui/layui.js"></script>
<script src="../../../layuiadmin/lib/juicer-min.js"></script>

<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'home','setter', 'auth', 'AppHelper', 'routerHelper'], function () {
        var $ = layui.$
            , form = layui.form
            , setter = layui.setter
            , home = layui.home
            , AppHelper = layui.AppHelper
            , util = layui.util
            , LayerPage = AppHelper.getLayerPage()
        ;
        var router = layui.router();
        // 自定义验证规则
        form.verify({
            // 确认密码
            confirmPassword: function(value, item){
                var passwordValue = $('#reg-password').val();
                if(value !== passwordValue){
                    return '两次密码输入不一致';
                }
            },
            max20: function (value, elem) {
                if (value && value.length > 100) {
                    return '不能大于 20 个字符';
                }
            }
        });

        form.on("submit(pwdForm-submit)", function (obj) {
            var field = obj.field;
            //保存
            var layerPageLoad = LayerPage.load();
            home.methods.pwd(field, 1)
                .done(function (res) {
                    if (res.code == "200") {
                        layerPageLoad.close();
                        form.render();
                        layer.msg("修改成功！", {icon: 1}, function () {
                        })
                    }
                })
                .fail(function () {
                    layerPageLoad.close();
                });
        })
    });
</script>
</body>
</html>
